from myapp import db


class User(db.Model):
    # 指定表名：默认使用类名小写
    __tablename__ = "users"
    uid = db.Column(db.Integer, primary_key=True)
    password = db.Column(db.String(255))
    # name = db.Column(db.String(64))

    def __repr__(self):
        return "(%s, %s)"%(self.uid, self.password)

class Image(db.Model):
    # 指定表名：默认使用类名小写
    __tablename__ = "pictrues"
    pid = db.Column(db.Integer, primary_key=True)
    fuid = db.Column(db.Integer)
    image = db.Column(db.Text)

    def __repr__(self):
        return "({}, {}, {})".format(self.pid, self.fuid, self.image)

class Proverb(db.Model):
    # 指定表名：默认使用类名小写
    __tablename__ = "proverbs"
    sid = db.Column(db.Integer, primary_key=True)
    sentence = db.Column(db.Text)
    author = db.Column(db.Text)

    def __repr__(self):
        return "({}, {}, {})".format(self.sid, self.sentence, self.author)

class Diary(db.Model):
    # 指定表名：默认使用类名小写
    __tablename__ = "diaries"
    did = db.Column(db.Integer, primary_key=True)
    content = db.Column(db.Text)
    images = db.Column(db.String(255))
    createdate = db.Column(db.Date)
    createtime = db.Column(db.DateTime)
    fuid = db.Column(db.Integer)
    diaryscore = db.Column(db.Integer)
    diaryemo = db.Column(db.String(255))

    def __repr__(self):
        return "({}, {}, {}, {}, {}, {}, {}, {})".format(self.did, self.content, self.images, self.createdate, self.createtime, self.fuid, self.diaryscore, self.diaryemo)